<?php
    if (!defined('EXPONENT')) exit('');
    global $user;
    if(exponent_users_isLoggedIn())
    {
        $profile_detail = $db->selectObject('profilemodule_profile',"user_id= ".$user->id);     
        $user_detail = $db->selectObject('user',"id= ".$user->id);     

        $profile_detail->firstname = $_REQUEST['firstname'];
        $profile_detail->company_name = $_REQUEST['company_name'];
        $profile_detail->lastname = $_REQUEST['lastname'];
        $profile_detail->tc_identity = $_REQUEST['tc_identity'];
        $profile_detail->email = $_REQUEST['email'];
        $profile_detail->website  = $_REQUEST['website'];
        $profile_detail->address = $_REQUEST['address'];
        $profile_detail->tel1 = $_REQUEST['tel1'];
        $profile_detail->tel2 = $_REQUEST['tel2'];
        $profile_detail->skype = $_REQUEST['skype'];
        $profile_detail->fax = $_REQUEST['fax'];
        $profile_detail->tax_number = $_REQUEST['tax_number'];
        $profile_detail->city = $_REQUEST['city'];
        $profile_detail->country = $_REQUEST['country'];
        $profile_detail->postcode = $_REQUEST['postcode'];
        $profile_detail->tax_office= $_REQUEST['tax_office'];
        //For user table
        $user_detail->firstname=$_REQUEST['firstname'];
        $user_detail->lastname=$_REQUEST['lastname'];
        $user_detail->email=$_REQUEST['email'];

        $update=$db->updateObject($profile_detail,'profilemodule_profile',"user_id= ".$user->id); 
        $update_user=$db->updateObject($user_detail,'user',"id= ".$user->id); 
        if($update&&$update_user)
            echo 'success';
        else
            echo 'no';
    }

    //NOT FINISH
    else
    {
        exponent_http_error(403);
    }
?>
